package jdk8;
import java.util.*;
import java.util.function.*;
/**
 * @author oldliu
 * @since 1.0
 */
public class Labmda2 {
    public static void foreach(List<String> arrays, Consumer<String> consumer){
        arrays.forEach(s -> consumer.accept(s));
    }
    public static Integer convert(String value, Function<String,Integer> function){
        return function.apply(value);
    }
    public static Integer getMin(Supplier<Integer> supplier){
        return supplier.get();
    }
    public static void main(String[] args) {
        List<String> arrays = new ArrayList<>();
        arrays.add("java");
        arrays.add("python");
        arrays.add("go");
        arrays.add("hive");

        arrays.forEach(System.out::println);

        foreach(arrays,s -> System.out.print(s+" "));
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>");

        Integer convert = convert("123", s -> Integer.parseInt(s)+14);
        System.out.println(convert);
        System.out.println(">>>>>>>>>>>>>>>>>>.");
        List<Integer> l2=Arrays.asList(1,2,5,7,8,25,6,66,23);
        Integer mm = getMin(() -> {
            int max = l2.get(0);
            for (int i = 1; i < l2.size(); i++) {
                if (max < l2.get(i))
                    max = l2.get(i);
            }
            return max;
        });
        System.out.println(mm);
    }
}
